package com.lagou.task17;

import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class DataOutputStreamTest {
    public static void main(String[] args) {
//        1.创建DataOutputStream对象与文件关联
        DataOutputStream dos = null;
        try {
            dos = new DataOutputStream(new FileOutputStream("a.txt"));
            //        2.写入数据
            int num = 66;
            dos.writeInt(num);
            System.out.println("数据写入成功");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
//        3.关闭数据流
            if (dos != null) {

                try {
                    dos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }


    }
}
